package com.hncc.kumao.tool;

import com.hncc.kumao.entity.BreakpointUploadTask;
import com.hncc.kumao.entity.NetdiskAccessToken;
import com.hncc.kumao.util.ConstValue;

public class UploadFileTool {

    //上传文件
    public void uploadFile(BreakpointUploadTask breakpointUploadTask, 
            NetdiskAccessToken netdiskAccessToken) throws Exception {
        switch (netdiskAccessToken.getNetdiskType()) {
        case ConstValue.NETDISK_TYPE_BAIDU:
            uploadBaiDuFile(breakpointUploadTask, netdiskAccessToken);
            break;
        case ConstValue.NETDISK_TYPE_JIANGUOYUN:
            uploadJianGuoYunFile(breakpointUploadTask, netdiskAccessToken);
            break;
        case ConstValue.NETDISK_TYPE_FTP:
            uploadFTPFile(breakpointUploadTask, netdiskAccessToken);
            break;
        case ConstValue.NETDISK_TYPE_SEAFILE:
            uploadSeafileFile(breakpointUploadTask, netdiskAccessToken);
            break;
        case ConstValue.NETDISK_TYPE_SMB:
            uploadSMBFile(breakpointUploadTask, netdiskAccessToken);
            break;
        }
    }
    
    //上传百度网盘文件
    public void uploadBaiDuFile(BreakpointUploadTask breakpointUploadTask, 
            NetdiskAccessToken netdiskAccessToken) throws Exception {
        try {
            System.out.println("上传百度网盘上的文件");
            BaiDuOperation.upload(breakpointUploadTask, netdiskAccessToken);
        } catch (Exception e) {
            //e.printStackTrace();
            throw e;
        }
    }
    
    //上传坚果云文件
    public void uploadJianGuoYunFile(BreakpointUploadTask breakpointUploadTask, 
            NetdiskAccessToken netdiskAccessToken) throws Exception {
        try {
            System.out.println("上传坚果云上的文件");
            JianGuoYunOperation.upload(breakpointUploadTask, netdiskAccessToken);
        } catch (Exception e) {
            //e.printStackTrace();
            throw e;
        }
    }
    
    //上传FTP文件
    public void uploadFTPFile(BreakpointUploadTask breakpointUploadTask, 
            NetdiskAccessToken netdiskAccessToken) throws Exception {
        try {
            System.out.println("上传FTP上的文件");
            FTPOperation.upload(breakpointUploadTask, netdiskAccessToken);
        } catch (Exception e) {
            //e.printStackTrace();
            throw e;
        }
    }
    
    //上传Seafile文件
    public void uploadSeafileFile(final BreakpointUploadTask breakpointUploadTask, 
            NetdiskAccessToken netdiskAccessToken) throws Exception {
        try {
            System.out.println("上传Seafile上的文件");
            SeafileOperation.upload(breakpointUploadTask, netdiskAccessToken);
        } catch (Exception e) {
            //e.printStackTrace();
            throw e;
        }
    }
    
    //上传SMB文件
    public void uploadSMBFile(BreakpointUploadTask breakpointUploadTask, 
            NetdiskAccessToken netdiskAccessToken) throws Exception {
        try {
            System.out.println("上传SMB上的文件");
            SMBOperation.upload(breakpointUploadTask, netdiskAccessToken);
        } catch (Exception e) {
            //e.printStackTrace();
            throw e;
        }
    }
}
